<?php
namespace Tbf\Component\BarCode\Tests;
use Tbf\Bundle\TestBundle\TestSuite\TbfTestCase;
use Tbf\Component\FileSystem\FileSystemFunction;
use Tbf\Component\BarCode\BarCodeFunction;
use Tbf\Component\BarCode\BarCodeRequest;

class BarCodeTest extends TbfTestCase{
    protected $file_path;
    function setUp(){
        $this->file_path = FileSystemFunction::getTmpFilePath('png');
    }
    function tearDown(){
        FileSystemFunction::delete($this->file_path);
    }
    function testQr(){
        BarCodeFunction::draw(BarCodeFunction::newRequest()
            ->setText('123456789')
            ->setType(BarCodeRequest::BARCODE_QR)
            ->setSaveFilePath($this->file_path)
        );
        $this->assertTrue(file_exists($this->file_path));
    }
    function testLinearBarcode(){
        BarCodeFunction::draw(BarCodeFunction::newRequest()
                ->setText('123456789')
                ->setType(BarCodeRequest::BARCODE_CODE128)
                ->setSaveFilePath($this->file_path)
        );
        $this->assertTrue(file_exists($this->file_path));
    }
}